import request from "@/service/request";
import {PromisePageResponse, PromiseResponse} from "@/service/api/type.ts";
import {SysUserInfoVo, SysUserVo} from "@/service/api/system/userRole/types.ts";

/**
 * 获取List数据
 * @param query
 */
const getUserList = (query: any): PromisePageResponse<SysUserVo> => {
  return request({
    url: '/system/user/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取全部角色和已分配给用户的勾选列表
 * @param userId
 * @param query
 */
const getRoleList = (userId: string, query: any): PromiseResponse<SysUserInfoVo> => {
  return request({
    url: `/system/user/allRole/${userId}`,
    method: "get",
    params: query,
  });
};

/**
 * 保存用户分配的角色按钮
 * @param userId
 * @param query
 */
const saveUserRoles = (userId: string, query: any): PromiseResponse<any> => {
  return request({
    url: `/system/user/authRoleBatch/${userId}`,
    method: "post",
    data: query,
  });
};

export {
  getUserList,
  getRoleList,
  saveUserRoles,
};
